-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series.to_dict does not return native Python types #37648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@pytest.mark.parametrize( | ||
"data,dtype", | ||
( | ||
[np.int64(9), int], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add unsigned int as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine, ,one comment.
and pls merge master |
Addressed comment + CI green modulo unrelated (a plotting test on each failing build) |
pandas/core/dtypes/cast.py
Outdated
elif is_integer_dtype(value): | ||
with suppress(ValueError, TypeError): | ||
value = int(value) | ||
elif is_bool_dtype(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use is_float/is_integer/is_bool checks instead of the is_foo_dtype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
comment on type/dtype checking, otherwise LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comment ping on green-ish
(Timestamp("2005-02-25"), Timestamp), | ||
(np.timedelta64(1, "D"), Timedelta), | ||
(Timedelta(1, "D"), Timedelta), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add other types which don't have an analog (e.g. Period / Interval, bytes) and so return themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@jreback there's a deprecation warning which turns into an error with np_dev
I'm positive it's caused by this PR - I don't get the warning locally on master but I do on this PR. I also think it's not a straightforward problem to debug and would prefer to address in a follow-on PR. Is that ok? Skipping the test for now with numpy dev and will open an issue to track |
this handled by #39854 don't skip the test just leave |
actually u already skipped so ok |
should get to green now |
@jreback ready to go i believe |
thanks @arw2019 |
@arw2019 Question about this, was this also supposed to fix/return
|
Timestamp can represent points in time that pydatetime cannot. im pretty sure this is intended. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This resolves the issue of return types from
to_dict
. #25969 also discusses return types from.items()
, which relates to an outstanding NumPy issue numpy/numpy#14139, and I don't address that part here atm